package data_stracture.Tree;

public class BiTree {

  //  Definition for a binary tree node.
    public static class TreeNode {
        String val;
        TreeNode left;
        TreeNode right;
    }

    public static void main(String[] args) {
        TreeNode treeNode = new TreeNode();
        String re = "";
        if (treeNode != null) {
            re = solution(treeNode.left) +treeNode.val+ solution(treeNode.right);
        }
        System.out.printf(re);

    }
    private static String solution(TreeNode treeNode){
        if (treeNode == null) {
            return "";
        }
        if(treeNode.left == null && treeNode.right == null)
            return treeNode.val;
        String leftString = solution(treeNode.left);
        String rightString = solution(treeNode.right);
        return "("+leftString+treeNode.val+rightString+")";
    }
}
